package com.cheng.chengliving.commodity.controller;

import com.cheng.chengliving.commodity.entity.SkuInfoEntity;
import com.cheng.chengliving.commodity.service.SkuInfoService;
import com.cheng.chengliving.commodity.vo.SearchResult;
import com.cheng.common.utils.PageUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author: 朱程
 * @Date: 2023/02/22/16:34
 * @Description:
 */
@Controller
public class SearchController {

    //装配SkuInfoService
    @Resource
    private SkuInfoService skuInfoService;
    /**
     * 1. 家居网前台（购买用户）-检索页面
     * 2. 如果将来检索的时候有检索条件，还需要进行处理..
     * 3. 用户提交的检索条件，我们封装到 params
     */
    @RequestMapping("/list.html")
    public String searchList(@RequestParam Map<String, Object> params, Model model) {

        SearchResult searchResult =
                skuInfoService.querySearchPageByCondition(params);



        //因为我们得到的 searchResult 是需要给html模板使用,
        //将searchResult放入model
        model.addAttribute("result",searchResult);

        return "list";
    }
}
